package hsb.ruoyi.admin.web.controller.system;

import hsb.ruoyi.common.core.controller.BaseController;
import hsb.ruoyi.common.core.domain.AjaxResult;
import hsb.ruoyi.common.core.domain.model.RegisterBody;
import hsb.ruoyi.common.utils.StringUtils;
import hsb.ruoyi.framework.web.service.SysRegisterService;
import hsb.ruoyi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
/**
 * 注册验证
 *
 * @author ruoyi
 */
@Produces(MediaType.APPLICATION_JSON)
public class SysRegisterController extends BaseController
{
    @Autowired
    private SysRegisterService registerService;

    @Autowired
    private ISysConfigService configService;

    @POST
    @Path("/register")
    public AjaxResult register( RegisterBody user)
    {
        if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
        {
            return error("当前系统没有开启注册功能！");
        }
        String msg = registerService.register(user);
        return StringUtils.isEmpty(msg) ? success() : error(msg);
    }
}
